package cn.jszx.core.query.user;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * 用户条件对象
 *
 * @author cjw
 * @Date [2015-9-15 下午06:58:00]
 */
public class UserQuery extends cn.jszx.core.query.BaseQuery {
    /**
     * ==============================批量查询、更新、删除时的Where条件设置======================
     * ============
     **/
    private String username;
    private boolean usernameLike;
    private String password;
    private boolean passwordLike;
    private String gender;
    private boolean genderLike;
    private String email;
    private boolean emailLike;
    private String realName;
    private boolean realNameLike;
    private Date registerTime;
    /**
     * 排序列表字段
     **/
    private List<OrderField> orderFields = new ArrayList<OrderField>();

    public String getUsername() {
        return username;
    }

    public UserQuery setUsername(String username) {
        this.username = username;
        return this;
    }

    public UserQuery setUsernameLike(boolean isLike) {
        this.usernameLike = isLike;
        return this;
    }

    public String getPassword() {
        return password;
    }

    public UserQuery setPassword(String password) {
        this.password = password;
        return this;
    }

    public UserQuery setPasswordLike(boolean isLike) {
        this.passwordLike = isLike;
        return this;
    }

    public String getGender() {
        return gender;
    }

    public UserQuery setGender(String gender) {
        this.gender = gender;
        return this;
    }

    public UserQuery setGenderLike(boolean isLike) {
        this.genderLike = isLike;
        return this;
    }

    public String getEmail() {
        return email;
    }

    public UserQuery setEmail(String email) {
        this.email = email;
        return this;
    }

    public UserQuery setEmailLike(boolean isLike) {
        this.emailLike = isLike;
        return this;
    }

    public String getRealName() {
        return realName;
    }

    public UserQuery setRealName(String realName) {
        this.realName = realName;
        return this;
    }

    public UserQuery setRealNameLike(boolean isLike) {
        this.realNameLike = isLike;
        return this;
    }

    public Date getRegisterTime() {
        return registerTime;
    }

    public UserQuery setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
        return this;
    }
    /**
     * ==============================批量查询时的Order条件顺序设置==========================
     * ========
     **/

    /**
     * 设置排序按属性：username
     *
     * @param isAsc 是否升序，否则为降序
     */
    public UserQuery orderbyUsername(boolean isAsc) {
        orderFields.add(new OrderField("username", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * 设置排序按属性：password
     *
     * @param isAsc 是否升序，否则为降序
     */
    public UserQuery orderbyPassword(boolean isAsc) {
        orderFields.add(new OrderField("password", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * 设置排序按属性：gender
     *
     * @param isAsc 是否升序，否则为降序
     */
    public UserQuery orderbyGender(boolean isAsc) {
        orderFields.add(new OrderField("gender", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * 设置排序按属性：email
     *
     * @param isAsc 是否升序，否则为降序
     */
    public UserQuery orderbyEmail(boolean isAsc) {
        orderFields.add(new OrderField("email", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * 设置排序按属性：real_name
     *
     * @param isAsc 是否升序，否则为降序
     */
    public UserQuery orderbyRealName(boolean isAsc) {
        orderFields.add(new OrderField("real_name", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * 设置排序按属性：register_time
     *
     * @param isAsc 是否升序，否则为降序
     */
    public UserQuery orderbyRegisterTime(boolean isAsc) {
        orderFields.add(new OrderField("register_time", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * ==============================批量查询时的Order条件顺序设置==========================
     * ========
     **/
    public class OrderField {
        private String fieldName;
        private String order;

        public OrderField(String fieldName, String order) {
            super();
            this.fieldName = fieldName;
            this.order = order;
        }

        public String getFieldName() {
            return fieldName;
        }

        public OrderField setFieldName(String fieldName) {
            this.fieldName = fieldName;
            return this;
        }

        public String getOrder() {
            return order;
        }

        public OrderField setOrder(String order) {
            this.order = order;
            return this;
        }
    }

}
